package com.ruoyi.web.controller.tool;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SysTalkBody;
import com.ruoyi.system.service.ISparkApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

/**
 * 星火控制器
 */
@RestController
@RequestMapping("/sparkApi")
public class SparkApiController {
    @Autowired
    private ISparkApiService sparkApiService;

    /**
     * 非流式 对话接口
     */
    @PostMapping("/communication")
    public AjaxResult communication(@RequestBody SysTalkBody sysTalkBody) {
        return AjaxResult.success(sparkApiService.communication(sysTalkBody));
    }

    /**
     * 流式 对话接口
     */
    @PostMapping(value = "/communicationStream",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> communicationStream(@RequestBody SysTalkBody sysTalkBody) {
        return sparkApiService.communicationStream(sysTalkBody);
    }

}
